<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="../js/vue.js"></script>
    <script type="text/javascript">Vue.config.productionTip = false</script>
    <title>vue练习</title>
</head>
<body>
    <div id="root">
        <h1>hello ,{{name}}</h1>
    </div>
    <div id="root2">
        <h1>hello</h1>
        <!-- 绑定点击事件 -->
        <button v-on:click="sun">dianji</button>
        <!-- 也可以简写为@ -->
        <button @click="sun">dianji</button>
    </div>
    <script type="text/javascript">
        const vm = new Vue({
            el:'#root',
            data:{
                name:"couno"
            }
        })
        const vm2 = new Vue({
            el:'#root2',
            data:{
                name:"couno"
            },
            methods:{ //这里是调用vm的方法，这里写可以免去数据中的冗余
                sun(){
                    alert("方法调用")
                }
            }
        })
    </script>
</body>
</html>